package com.example.pan.ext

import android.app.Activity
import android.content.Intent
import android.os.Build
import android.view.WindowInsets
import android.view.WindowManager
import com.google.gson.Gson

fun Activity.startActivity(clazz: Class<Any>) {
    startActivity(Intent(this, clazz))
}

fun Activity.fullScreen() {
    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.R) {
        window.insetsController?.hide(WindowInsets.Type.statusBars())
    } else {
        window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
    }
}


fun <K, V> Map<K, V>.toJson(): String = Gson().toJson(this)

fun <T> String.toBean(clazz: Class<T>): T = Gson().fromJson(this, clazz)
